home *** CD-ROM | disk | FTP | other *** search
- /*
- File: MemoryClass.h
-
- Contains: TMemory is a simple object checks heap and stack values, as well as changes them.
- TMemoryClass.h contains the TMemory class definitions.
-
- Written by: Kent Sandvik
-
- Copyright: Copyright © 1999 by Apple Computer, Inc., All Rights Reserved.
-
- You may incorporate this Apple sample source code into your program(s) without
- restriction. This Apple sample source code has been provided "AS IS" and the
- responsibility for its operation is yours. You are not permitted to redistribute
- this Apple sample source code as "Apple sample source code" after having made
- changes. If you're going to re-distribute the source, we require that you make
- it clear in the source that the code was descended from Apple sample source
- code, but that you've made changes.
-
- Change History (most recent first):
- 8/18/1999 Karl Groethe Updated for Metrowerks Codewarror Pro 2.1
-
-
- */
- // Declare label for this header file
- #ifndef _MEMORYCLASS_
- #define _MEMORYCLASS_
-
- #ifndef _DTSCPLUSLIBRARY_
- #include "DTSCPlusLibrary.h"
- #endif
-
- // TOOLBOX INCLUDES
- #ifndef __MEMORY__
- #include <Memory.h>
- #endif
-
- #ifndef __RESOURCES__
- #include <Resources.h>
- #endif
-
- #ifndef __TYPES__
- #include <Types.h>
- #endif
-
- // GLOBAL DEFINITIONS
- const OSType kStackResource = 'stak'; // definition of our resource for defining stack size
-
-
- // _________________________________________________________________________________________________________ //
- // TMemory Class Interface.
- class TMemory
- // TMemory is a simple memory utility class that keeps track of size of the stack and heap, and could
- // be used to manipulate the memory sizes.
- {
- public:
- // TYPEDEFS AND ENUMS
- enum EConstants // constants used in the TMemory class
- {
- kNoMinHeap = 0, kNoMinStack = 0
- };
-
- // CONSTRUCTORS AND DESTRUCTORS
- TMemory(const long minHeap = kNoMinHeap,
- // default constructor
- // default constructor
- const long minStack = kNoMinStack);
- virtual~ TMemory(); // default destructor
-
- // MAIN INTERFACE
- virtual long GetStackSize(); // get size of stack
- virtual Boolean SetStackSize(const long stackValue);// set new stack size
- virtual Boolean SetStackSizeFromResources();// set stack sizes based on resource information
- virtual Boolean IncreaseStackSize(const long stackValue);// increase the current stack size
- virtual Boolean CheckStackSize(); // check if selected min stack size is OK
- virtual Boolean CheckHeapSize(); // check if selected min heap size is OK
-
- virtual long GetHeapSize(); // get size of heap
-
- // FIELDS
- protected:
- long fMinHeap; // minimum heap size
- long fMinStack; // minimum stack size
- OSErr fError; // latest error
-
- // PRIVATE STRUCTURES
- private:
- struct StackResource // for the kStackResource resource mapping
- {
- long stackVal; // the new stack size
- };
-
-
- typedef StackResource* StackValuePtr; // typecasted for handy re-use
- typedef StackResource** StackValueHandle;
- };
-
-
- #endif
-
- // _________________________________________________________________________________________________________ //
-
- /* Change History (most recent last):
- No Init. Date Comment
- 1 khs 1/2/93 New file
- 2 khs 1/3/93 Cleanup
- */
-